//
//  CatagoryModel.m
//  Kugou-OC
//
//  Created by BH on 16/6/14.
//  Copyright © 2016年 Sunny. All rights reserved.
//

#import "CatagoryModel.h"

@implementation CatagoryChildrenModel

-(id)initWithDict:(NSDictionary *)dict{
    self = [super init];
    if (self) {
        self.childrenID = dict[@"id"];
        self.childrenName = dict[@"name"];
        self.song_tag_id = dict[@"song_tag_id"];
        self.special_tag_id = dict[@"special_tag_id"];
        self.album_tag_id = dict[@"album_tag_id"];
        self.imgurl = dict[@"imgurl"];
        self.bannerurl = dict[@"bannerurl"];
        self.icon = dict[@"icon"];
        self.jump_url = dict[@"jump_url"];
        self.is_new = [dict[@"is_new"] boolValue];
        self.is_hot = [dict[@"is_hot"] boolValue];
        self.has_child = [dict[@"has_child"] boolValue];
    }
    
    return self;
}

@end

@implementation CatagoryModel

-(NSMutableArray *)childrens{
    if (_childrens == nil) {
        _childrens = [NSMutableArray array];
    }
    
    return _childrens;
}

-(id)initWithDict:(NSDictionary *)dict{
    self = [super init];
    if (self) {
        self.catagoryID = dict[@"id"];
        self.catagoryName = dict[@"name"];
        self.iconUrl = dict[@"icon"];
        self.has_child = [dict[@"has_child"] boolValue];
        
        NSArray *temp = dict[@"children"];
        for (NSDictionary *subDict in temp) {
            self.children = [[CatagoryChildrenModel alloc] initWithDict:subDict];
            [self.childrens addObject:self.children];
        }
    }
    
    return self;
}

@end
